package study.javaee.practice.service;

import cn.hutool.crypto.symmetric.SymmetricAlgorithm;
import cn.hutool.crypto.symmetric.SymmetricCrypto;

import javax.crypto.SecretKey;
import javax.servlet.http.HttpServletRequest;

/**
 * 对称加密服务
 */
public interface SymEncService {
    String decryptToStr(String strForm, byte[] key);

    /**
     *
     * @param b64EncData 使用base64编码的数据
     * @return 解码后的Json字符串
     */
    String decryptToStr(String b64EncData, SymmetricCrypto crypto);
    String decryptToStr(String b64EncData, SecretKey key);

    String encryptToStr(String data, SymmetricCrypto crypto);
    String encryptToStr(String jsonData, SecretKey key);

    SecretKey generateSecretKey(String sKey, String iv);
    SecretKey generateSecretKey(String sKey);

    SymmetricCrypto generateCrypto(String sKey, String iv);
    SymmetricCrypto generateCrypto(String sKey);
    SymmetricCrypto setCrypto(String key, String iv, HttpServletRequest request);
    SymmetricCrypto getCrypto(HttpServletRequest request);

    String getEncType();

}
